﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace APPLICATION
{
    public partial class SettingsConfig : Form
    {
        public SettingsConfig()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            APPLICATION.Properties.Settings.Default.ServerAdress = txtServerAdress.Text;
            APPLICATION.Properties.Settings.Default.DatabaseName = txtDatabaseName.Text;
           

            //  This  Part shoud  be  removed in future
            //  APPLICATION.Properties.Settings.Default.UserName = txtUserName.Text;
            //  APPLICATION.Properties.Settings.Default.Password = txtPassword.Text;
            
            /*
            GetConnectionString connString = new GetConnectionString();
            using (SqlConnection connection = new SqlConnection(connString.connString()))
            {
                try
                {
                    connection.Open();
                    this.DialogResult = DialogResult.OK;
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Database  Connection  Error !!! Try again ");
                }
            }

            */

            APPLICATION.Properties.Settings.Default.Save();
            
            Close();
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void SettingsConfig_Load(object sender, EventArgs e)
        {
            txtServerAdress.Text = APPLICATION.Properties.Settings.Default.ServerAdress;
            txtDatabaseName.Text = APPLICATION.Properties.Settings.Default.DatabaseName;
           
        }
    }
}
